package com.csxy.six.util;

import com.csxy.six.dto.CommentDTO;
import com.csxy.six.entity.LostFoundComment;

public class BeanConverter {

    public static CommentDTO toCommentDTO(LostFoundComment comment) {
        CommentDTO dto = new CommentDTO();
        dto.setCommentId(comment.getCommentId());
        dto.setUserId(comment.getUserId());
        dto.setItemId(comment.getLostId() != null ? comment.getLostId() : comment.getFoundId());
        dto.setItemType(comment.getLostId() != null ? 1 : 2);
        dto.setContent(comment.getContent());
        dto.setCreateTime(comment.getCreatedAt());

        // 需要从UserService获取用户信息
        // User user = userService.getById(comment.getUserId());
        // if (user != null) {
        //     dto.setUsername(user.getNickname());
        //     dto.setAvatar(user.getAvatar());
        // }

        return dto;
    }
}